<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org" lang="zh">

<head>
    <link rel="StyleSheet" href="../../static/css/jpetstore.css" type="text/css"
          media="screen" />

    <meta name="generator"
          content="HTML Tidy for Linux/x86 (vers 1st November 2002), see www.w3.org" />
    <title>JPetStore Demo</title>
    <meta content="text/html; charset=windows-1252"
          http-equiv="Content-Type" />
    <meta http-equiv="Cache-Control" content="max-age=0" />
    <meta http-equiv="Cache-Control" content="no-cache" />
    <meta http-equiv="expires" content="0" />
    <meta http-equiv="Expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
    <meta http-equiv="Pragma" content="no-cache" />
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
</head>

<body>

<div th:include="~{common/commonSide::topbar}"></div>


<div id="Catalog">

    <table>
        <tr>
            <td th:utext="${product.desCn}">descn</td>
        </tr>
        <tr>
            <td th:text="${item.itemid}" style="font-weight:bold" id="itemid">
        </tr>
        <tr>
            <td th:text="${item.attr1}" style="font-weight:bold"></td>
        </tr>
        <tr>
            <td th:text="${product.name}"></td>
        </tr>
        <tr>
            <td>
            <span th:if = "${item.getStatus() != 'P'}" style="font-weight: bold">Back ordered.</span>
            <span th:if = "${item.getStatus() == 'P'}" style="font-weight: bold">On sale.</span>
            </td>
        </tr>
        <tr>
            <td>
                <a th:if = "${item.getStatus() != 'P'}" href="#" onclick="changestatu()">On shelf</a>
                <a th:if = "${item.getStatus() == 'P'}" href="#" onclick="changestatu()">Off shelf</a>
             </td>
        </tr>
        <script>

            function changestatu(){
                var itemId = $("#itemid").text()
                var data = {
                    'itemId':itemId
                }
                $.ajax({
                    type: 'post',
                    url: '/admin/item/status',
                    data: JSON.stringify(itemId),
                    contentType: 'application/json;charset=utf-8',
                    dataType: 'json',
                    success: function (responseData) {
                        console.log(responseData)
                        window.location=`/admin/item/${itemId}`

                    }
                })
            }
        </script>
    </table>


</div>

<div th:include="~{common/commonSide::footer}"></div>

</body>
</html>


